styleproperty: Make default_value() take a state
authorBenjamin Otte <otte@redhat.com>
Sun, 12 Jun 2011 23:26:11 +0000 (01:26 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 13 Jun 2011 13:01:52 +0000 (15:01 +0200)
Because of this, resolve() needs to take a state, too. This is so that
we can have default values depend on other values (like border color).

gtk/gtkstyleproperties.c
gtk/gtkstyleproperty.c
gtk/gtkstylepropertyprivate.h

index 6af179b9ec81b0f46294c5694d6e40f8dc1767db..458fcaa2fb32e033345bdbc282ac8e8bd529e5e2 100644 (file)
@@ -669,7 +669,7 @@ _gtk_style_properties_peek_property (GtkStyleProperties      *props,
   if (val == NULL)
     return NULL;
   
-  _gtk_style_property_resolve (node, props, val);
+  _gtk_style_property_resolve (node, props, state, val);
 
   return val;
 }
@@ -713,7 +713,7 @@ gtk_style_properties_get_property (GtkStyleProperties *props,
   else if (_gtk_style_property_is_shorthand (node))
     _gtk_style_property_pack (node, props, state, value);
   else
-    _gtk_style_property_default_value (node, props, value);
+    _gtk_style_property_default_value (node, props, state, value);
 
   return TRUE;
 }
@@ -767,7 +767,7 @@ gtk_style_properties_get_valist (GtkStyleProperties *props,
           GValue default_value = { 0 };
 
           g_value_init (&default_value, node->pspec->value_type);
-          _gtk_style_property_default_value (node, props, &default_value);
+          _gtk_style_property_default_value (node, props, state, &default_value);
           G_VALUE_LCOPY (&default_value, args, 0, &error);
           g_value_unset (&default_value);
         }
index e8a2114e89f7b25036260de54ee1b035c507cf6f..2de24a997daddcb8ee640be888e66ce5e86e2e32 100644 (file)
@@ -1683,6 +1683,7 @@ pack_border_radius (GValue             *value,
 
 static void
 border_image_width_default_value (GtkStyleProperties *props,
+                                  GtkStateFlags       state,
                                   GValue             *value)
 {
 }
@@ -1858,10 +1859,11 @@ _gtk_style_property_print_value (const GtkStyleProperty *property,
 void
 _gtk_style_property_default_value (const GtkStyleProperty *property,
                                    GtkStyleProperties     *properties,
+                                   GtkStateFlags           state,
                                    GValue                 *value)
 {
   if (property->default_value_func)
-    property->default_value_func (properties, value);
+    property->default_value_func (properties, state, value);
   else if (property->pspec->value_type == GTK_TYPE_THEMING_ENGINE)
     g_value_set_object (value, gtk_theming_engine_load (NULL));
   else if (property->pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
@@ -1970,6 +1972,7 @@ resolve_shadow (GtkStyleProperties *props,
 void
 _gtk_style_property_resolve (const GtkStyleProperty *property,
                              GtkStyleProperties     *props,
+                             GtkStateFlags           state,
                              GValue                 *val)
 {
   if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR)
@@ -1987,12 +1990,12 @@ _gtk_style_property_resolve (const GtkStyleProperty *property,
       
       g_value_unset (val);
       g_value_init (val, property->pspec->value_type);
-      _gtk_style_property_default_value (property, props, val);
+      _gtk_style_property_default_value (property, props, state, val);
     }
   else if (G_VALUE_TYPE (val) == GDK_TYPE_RGBA)
     {
       if (g_value_get_boxed (val) == NULL)
-        _gtk_style_property_default_value (property, props, val);
+        _gtk_style_property_default_value (property, props, state, val);
     }
   else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT)
     {
@@ -2002,13 +2005,13 @@ _gtk_style_property_resolve (const GtkStyleProperty *property,
         {
           g_value_unset (val);
           g_value_init (val, CAIRO_GOBJECT_TYPE_PATTERN);
-          _gtk_style_property_default_value (property, props, val);
+          _gtk_style_property_default_value (property, props, state, val);
         }
     }
   else if (G_VALUE_TYPE (val) == GTK_TYPE_SHADOW)
     {
       if (!resolve_shadow (props, val))
-        _gtk_style_property_default_value (property, props, val);
+        _gtk_style_property_default_value (property, props, state, val);
     }
 }
 
index afa76be616ef7adf1ec5f287cfeda9d644ed9b52..db8706843f72df25ddb24e5c6b34ff12ca76ecda 100644 (file)
@@ -40,6 +40,7 @@ typedef gboolean         (* GtkStyleParseFunc)             (GtkCssParser
 typedef void             (* GtkStylePrintFunc)             (const GValue           *value,
                                                             GString                *string);
 typedef void             (* GtkStyleDefaultValueFunc)      (GtkStyleProperties     *props,
+                                                            GtkStateFlags           state,
                                                             GValue                 *value);
 
 
@@ -71,10 +72,12 @@ gboolean                 _gtk_style_property_is_inherit    (const GtkStyleProper
 
 void                     _gtk_style_property_default_value (const GtkStyleProperty *property,
                                                             GtkStyleProperties     *properties,
+                                                            GtkStateFlags           state,
                                                             GValue                 *value);
 
 void                     _gtk_style_property_resolve       (const GtkStyleProperty *property,
                                                             GtkStyleProperties     *properties,
+                                                            GtkStateFlags           state,
                                                             GValue                 *value);
 
 gboolean                 _gtk_style_property_is_shorthand  (const GtkStyleProperty *property);